package com.jy.rhin.domain.notification.publish.entity;

import java.util.function.BiPredicate;

/**
 * @author WeiQ
 * @date 2022/7/5 9:15
 * 主题预存查询过滤条件比较表达式
 */
public enum EnumTopicQueryFilterCompareExp {
    /**
     * 比较表达式 LT:<  LE:<=   EQ:=  GE:>=  GT:>
     */
    LT((value, target) -> value.compareTo(target) < 0),
    LE((value, target) -> value.compareTo(target) <= 0),
    EQ((value, target) -> value.compareTo(target) == 0),
    GE((value, target) -> value.compareTo(target) >= 0),
    GT((value, target) -> value.compareTo(target) > 0),
    ;

    final BiPredicate<String, String> compare;

    EnumTopicQueryFilterCompareExp(BiPredicate<String, String> compare) {
        this.compare = compare;
    }

    public boolean compare(String value, String target) {
        return this.compare.test(value, target);
    }

}
